// ground
import * as THREE from 'three'
export const ground1 = (() => {
  const color = 0x00aa00
  const ground = new THREE.Mesh(
    new THREE.PlaneGeometry(200, 200),
    new THREE.MeshPhongMaterial({ color, depthWrite: false }),
  )
  ground.rotation.x = -Math.PI / 2
  // ground.rotation.x = Math.PI /18
  ground.receiveShadow = true
  return ground
})()

export const ground2 = (() => {
  const planeSize = 40
  const loader = new THREE.TextureLoader()
  const texture = loader.load('resources/images/checker.png')
  texture.wrapS = THREE.RepeatWrapping
  texture.wrapT = THREE.RepeatWrapping
  texture.magFilter = THREE.NearestFilter
  texture.colorSpace = THREE.SRGBColorSpace
  const repeats = planeSize / 2
  texture.repeat.set(repeats, repeats)

  const planeGeo = new THREE.PlaneGeometry(planeSize, planeSize)
  const planeMat = new THREE.MeshPhongMaterial({
    map: texture,
    side: THREE.DoubleSide,
  })
  const mesh = new THREE.Mesh(planeGeo, planeMat)
  mesh.rotation.x = Math.PI * -0.5
  return
})()
